package com.ruoyi.app.controller;

import com.ruoyi.app.domain.AppDonations;
import com.ruoyi.app.domain.AppReturnReservations;
import com.ruoyi.app.service.IAppDonationsService;
import com.ruoyi.app.service.IAppReturnReservationsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@RequestMapping ("/api")
public class AppBaseController extends BaseController {

    @Autowired
    private IAppDonationsService appDonationsService;
    @Autowired
    private IAppReturnReservationsService appReturnReservationsService;

    /**
     * 捐赠相关接口
     * @author XiaoWu
     * @date 2025/11/04
     */

    /**
     * 查询捐款详情
     * @param id 捐款主键
     * @return 捐款详情
     */
     @GetMapping("/donations/{id}")
    public AppDonations selectAppDonationsById(@PathVariable("id") Long id)
    {
        return appDonationsService.selectAppDonationsById(id);
    }

    /**
     * 查询捐款列表
     * @param appDonations 捐款
     * @return 捐款集合
     */
     @GetMapping("/donations/Xiaowu_list")
    public List<AppDonations> selectAppDonationsList(AppDonations appDonations)
    {
        return appDonationsService.selectAppDonationsList(appDonations);
    }

    /**
     * 新增捐款
     * @param appDonations 捐款
     * @return 结果
     */
     @PostMapping("/donations/Xiaowu_add")
     public AjaxResult add(@RequestBody AppDonations appDonations)
     {
         return toAjax(appDonationsService.insertAppDonations(appDonations));
     }

    /**
     * 修改捐款
     * @param appDonations 捐款
     * @return 结果
     */
     @PutMapping("/donations/Xiaowu_update")
     public AjaxResult edit(@RequestBody AppDonations appDonations)
     {
         return toAjax(appDonationsService.updateAppDonations(appDonations));
     }

    /**
     * 删除捐款
     * @param ids 捐款主键
     * @return 结果
     */
     @DeleteMapping("/donations/Xiaowu_delete/{ids}")
     public AjaxResult remove(@PathVariable Long[] ids)
     {
         return toAjax(appDonationsService.deleteAppDonationsByIds(ids));
     }

    /**
     * 返校预约相关接口
     * @author XiaoWu
     * @date 2025/11/04
     */

    /**
     * 查询返校预约详情
     * @param id 返校预约主键
     * @return 返校预约详情
     */
    @GetMapping(value = "/reservations/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appReturnReservationsService.selectAppReturnReservationsById(id));
    }

    /**
     * 查询返校预约列表
     * @param appReturnReservations 返校预约
     * @return 返校预约集合
     */
    @GetMapping("/reservations/Xiaowu_list")
    public TableDataInfo list(AppReturnReservations appReturnReservations)
    {
        startPage();
        List<AppReturnReservations> list = appReturnReservationsService.selectAppReturnReservationsList(appReturnReservations);
        return getDataTable(list);
    }

    /**
     * 新增返校预约
     * @param appReturnReservations 返校预约
     * @return 结果
     */
    @PostMapping("/reservations/Xiaowu_add")
    public AjaxResult add(@RequestBody AppReturnReservations appReturnReservations)
    {
        return toAjax(appReturnReservationsService.insertAppReturnReservations(appReturnReservations));
    }

    /**
     * 修改返校预约
     * @param appReturnReservations 返校预约
     * @return 结果
     */
    @PutMapping("/reservations/Xiaowu_update")
    public AjaxResult edit(@RequestBody AppReturnReservations appReturnReservations)
    {
        return toAjax(appReturnReservationsService.updateAppReturnReservations(appReturnReservations));
    }

    /**
     * 删除返校预约
     * @param ids 返校预约主键
     * @return 结果
     */
    @DeleteMapping("/reservations/Xiaowu_delete/{ids}")
    public AjaxResult delete(@PathVariable Long[] ids)
    {
        return toAjax(appReturnReservationsService.deleteAppReturnReservationsByIds(ids));
    }
}
